package com.crm.asset.controller;

import com.crm.asset.entity.ProdInst;
import com.crm.asset.service.ProdInstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/assetcenter/prodinsts")
public class ProdInstController {
    @Autowired
    private ProdInstService prodInstService;
    @PostMapping
    public Long add(@RequestBody ProdInst prodInst){
        return prodInstService.add(prodInst);
    }
    @DeleteMapping("{prodInstId}")
    public int del(@PathVariable("prodInstId") Long prodInstId){
        return prodInstService.delete(prodInstId);
    }
    @PutMapping("{prodInstId}")
    public int update(@PathVariable("prodInstId") Long prodInstId,@RequestBody ProdInst prodInst){
        prodInst.setProdInstId(prodInstId);
        return prodInstService.update(prodInst);
    }
    @GetMapping("{prodInstId}")
    public ProdInst get(@PathVariable("prodInstId")Long prodInstId){
        return prodInstService.get(prodInstId);
    }
    @GetMapping
    public List<ProdInst> query(Long prodId, Long custId, String accNum){
        return prodInstService.query(prodId,custId,accNum);
    }
    @GetMapping("page")
    public List<ProdInst> queryPage(Long prodId, Long custId, String accNum){
        return prodInstService.query(prodId,custId,accNum);
    }
}
